#ifndef NODE
#define NODE
 
//航班信息结构体
typedef struct flight{
    
    char id[16];            //航班号
    char begaddr[16];       //起点站
    char endaddr[16];       //终点站
    char fldate[16];        //班期 
    char fltype[16];        //航班类型（属于哪家公司）
    char begtime[8];        //起飞时间
    char endtime[8];        //到达时间
    float fare;             //票价
 
}flight_t;
 
//双向循环链表结构
typedef struct dclinklist{
 
    struct dclinklist* before;      //前面一个节点
    flight_t* flight;               //存储航班
    struct dclinklist* next;        //下一个节点
 
}dclist_t;
 
#endif
 
//创建双向循环链表的头
dclist_t* create_dclist();
//添加航班
int insert_flight(dclist_t* dchead, flight_t* flight);
//节点数，不包括头
int length_dclist(dclist_t* dchead);
 
typedef void (*showfun_t)(flight_t* flight);
//航线
void showRoute(flight_t* flight);
void showTime(flight_t* flight);
void showFare(flight_t* flight);
void showData(flight_t* flight);
void showType(flight_t* flight);
void showAll(flight_t* flight);
//打印函数
void print_flight(dclist_t* head, showfun_t showFun);
 
//比较函数指针(第一个是链表中本身的数据，第二个是页面传过来的数据)
typedef int (*comparefun_t)(flight_t * dclistFlight, flight_t* flight);
int compareId(flight_t * dclistFlight, flight_t* flight);
int compareType(flight_t* dclistFlight, flight_t* flight);
int compareFldate(flight_t* dclistFlight, flight_t* flight);
//根据航班号删除航班
int delete_dclist(dclist_t* dchead, flight_t * id, comparefun_t comparefun);
//删除尾节点
int delete_tdclist(dclist_t * dchead);
 
//根据航班号修改航班中时间信息
int updata_dclist(dclist_t* dchead, flight_t * flight, comparefun_t comparefun);
//按照类型查询航班
int find_flight_type(dclist_t* dchead, flight_t* flight, comparefun_t comparefun, showfun_t showfun);
//根日期票价排序查看航班
int sort_flight_date_fare(dclist_t* dchead);
//根据起始地和目的地查询航班
int find_flight_begaddr_endaddr(dclist_t* dchead, flight_t* flight);
//根据日期查询航班
int find_flight_fldate(dclist_t* dchead, flight_t* flight);
 
//从链表中的数据保存到文件中
void save_flight_file(dclist_t* dchead);
//添加一条航班就往文件中保存
void write_flight_file(dclist_t* dchead);
//从文件中读取航班
void read_flight_file(dclist_t* dchead);
 